package cn.xjt.safeList;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * 一个比较安全的集合类
 * @author xujiangtao
 * @create 2020-08-01-16:49
 */
public class TestCopyOnWriteAyyayList {
    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        new Thread(()->
        {
            for (int i = 0; i < 100; i++) {
                list.add(Thread.currentThread().getName()+i);
            }
            System.out.println(list.size());
        }).start();
    }
}
